package com.example.ch03_linearlayout2;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {
	// �ŧi�e���W,�{���n�������
	private EditText nameInput;
	private Button sayHiBtn;
	private TextView resultLabel;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		initView();
		initHandler();

	}

	private void initHandler() {
		// TODO Auto-generated method stub
		sayHiBtn.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				String s = nameInput.getText().toString();
				resultLabel.setText("Hello "+s);
			}
		});
	}

	private void initView() {
		// TODO Auto-generated method stub
		nameInput = (EditText) this.findViewById(R.id.nameInput);
		sayHiBtn = (Button)this.findViewById(R.id.sayHiBtn);
		resultLabel = (TextView) this.findViewById(R.id.resultLabel);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
